package edu.hawaii.wicket;

import java.util.HashMap;
import java.util.Map;
import org.apache.wicket.Request;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.protocol.http.WebSession;

/**
 * Provide a very simple session data structure, which is just a set of string key-value pairs.
 * The session should typically store all of the "model" data for a user. 
 * @author Philip Johnson
 */
public class ExampleApplicationSession extends WebSession {
  /** Support serialization. */
  private static final long serialVersionUID = 1L;
  /** Each user has a set of properties. */
  private Map<String, String> properties = new HashMap<String, String>();

  /**
   * Create a new session for this user. Called automatically by wicket. You always need to define
   * this constructor when implementing your own application-specific Session class.
   * 
   * Creates default values for width and height, used by FormPage.
   * 
   * @param application This application.
   * @param request The request.
   */
  public ExampleApplicationSession(WebApplication application, Request request) {
    super(request);
    this.properties.put("Width", "300");
    this.properties.put("Height", "300");
  }

  /**
   * Return the properties instance for this specific user.
   * 
   * @return The properties.
   */
  public Map<String, String> getProperties() {
    return this.properties;
  }
}
